<template>
	<div class="content">
		<view>
			<div class="weather-forecast">
				<image src="../../static/weather/ww.jpeg" mode="" style="width: 100%;height: 200px;"></image>
				<!-- <h2>天气预报</h2> -->
				<view class="icon">
					<view class="weather" v-for="(item,index) in weather" :key="index">
						<view class="text" style="font-size: 40rpx;margin-left: 3px;">
							{{item.fxDate}}
						</view>
						<view class="text" style="font-size: 34rpx;margin-left: 10px;">
							{{item.tempMax}}°C/{{item.tempMin}}°C
						</view>
						<view class="text" style="font-size: 35rpx;margin-left: 3px;">
							{{item.textDay}}
						</view>
						<view class="text" style="margin-left: 10rpx;">
							湿度:{{item.humidity }}%
						</view>
					</view>
				</view>
			</div>
		</view>
	</div>

</template>

<script setup>
	import {
		ref
	} from "vue"

	import {
		onLoad
	} from '@dcloudio/uni-app'

	import {
		CONFIG,
		headers1
	} from '../../utils/config';

	onLoad(() => {
		getWeather()
	})

	let weather = ref({})

	async function getWeather() {
		let res = await uni.$get(CONFIG.hefeng_7d, {
			key: CONFIG.hefeng_key,
			location: CONFIG.hefeng_locition
		})
		if (res.code == 200) {
			weather.value = res.daily
			console.log(res.daily)
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #00c4be;
	}

	.weather {
		height: 100px;
		border: 1px solid #000000;
		margin: 5px;
		border-radius: 5px;
		display: flex;
		justify-content: space-between;
		padding: 10px;
		align-items: center;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		/* 添加阴影效果 */
		background-color: #f9f9f9;
		/* 设置背景颜色 */
		font-family: 'Arial', sans-serif;
		/* 设置字体 */
	}
</style>